package cn.ibizlab.odoo.core.odoo_purchase.service.impl;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.math.BigInteger;
import java.util.Collection;

import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import cn.ibizlab.odoo.core.client.model.Ipurchase_order;
import cn.ibizlab.odoo.core.odoo_purchase.domain.Purchase_order;
import cn.ibizlab.odoo.core.odoo_purchase.filter.Purchase_orderSearchContext;
import cn.ibizlab.odoo.core.odoo_purchase.service.IPurchase_orderService;
import cn.ibizlab.odoo.util.SearchResult;
import cn.ibizlab.odoo.util.log.IBIZLog;

/**
 * 实体[采购订单] 服务对象接口实现
 */
@Slf4j
@IBIZLog
@Service
public class Purchase_orderServiceImpl implements IPurchase_orderService {

    @Autowired
    private cn.ibizlab.odoo.core.client.service.Ipurchase_orderClientService purchase_orderClientService;

    @Override
    public Purchase_order get(Integer id) {
        Ipurchase_order clientModel = purchase_orderClientService.createModel();
        clientModel.setId(id);
        purchase_orderClientService.get(clientModel) ;
        return this.convert2Domain(clientModel,null);
    }

    @Override
    public Purchase_order get(Purchase_order purchase_order) {
        Purchase_order retpurchase_order = this.get(purchase_order.getId()) ;
    	BeanCopier copier=BeanCopier.create(retpurchase_order.getClass(), purchase_order.getClass(), false);
        copier.copy(retpurchase_order, purchase_order, null);
        return purchase_order ;
    }

    @Override
    public void updateBatch(List<Purchase_order> purchase_orders, int batchSize) {

        //purchase_orderClientService.updateBatch(purchase_orders,batchSize) ;

    }

    @Override
    public void removeBatch(Collection<? extends Serializable> idList, int batchSize) {

        //purchase_orderClientService.removeBatch(purchase_orders) ;

    }

    @Override
    public boolean remove(Integer id) {
        boolean bOk = false ;
        Ipurchase_order clientModel = purchase_orderClientService.createModel();
        clientModel.setId(id);
        purchase_orderClientService.remove(clientModel) ;
        bOk = true ;
        return bOk ;
    }

    @Override
    public boolean update(Purchase_order purchase_order) {
        boolean bOk = false ;
        Ipurchase_order clientModel = this.convert2Model(purchase_order,null);
        purchase_orderClientService.update(clientModel) ;
        this.convert2Domain(clientModel,purchase_order) ;
        bOk = true;
        return bOk ;
    }

    @Override
    public boolean create(Purchase_order purchase_order) {
        boolean bOk = false ;
        Ipurchase_order clientModel = this.convert2Model(purchase_order,null);
        purchase_orderClientService.create(clientModel) ;
        this.convert2Domain(clientModel,purchase_order);
        bOk = true ;

        return bOk ;
    }

    @Override
    public void createBatch(List<Purchase_order> purchase_orders, int batchSize) {

                        //purchase_orderClientService.createBatch(purchase_orders,batchSize) ;

    }

    /**
     * 查询集合 默认查询
     */
    @Override
    public Page<Purchase_order> searchDefault(Purchase_orderSearchContext context) {
        List<Purchase_order> list = new ArrayList<Purchase_order>();
        Page<cn.ibizlab.odoo.core.client.model.Ipurchase_order> clientModelList = purchase_orderClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ipurchase_order clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Purchase_order>(list, context.getPageable(), clientModelList.getTotalElements());
    }


    /**
     * 根据税科目调整查询
     */
    @Override
    public Page<Purchase_order> selectByOdoo_fiscal_position(Integer id){
        Purchase_orderSearchContext context = new Purchase_orderSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Purchase_order> list = new ArrayList<Purchase_order>();
        Page<cn.ibizlab.odoo.core.client.model.Ipurchase_order> clientModelList = purchase_orderClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ipurchase_order clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Purchase_order>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据贸易条款查询
     */
    @Override
    public Page<Purchase_order> selectByOdoo_incoterm(Integer id){
        Purchase_orderSearchContext context = new Purchase_orderSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Purchase_order> list = new ArrayList<Purchase_order>();
        Page<cn.ibizlab.odoo.core.client.model.Ipurchase_order> clientModelList = purchase_orderClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ipurchase_order clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Purchase_order>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据付款条款查询
     */
    @Override
    public Page<Purchase_order> selectByOdoo_payment_term(Integer id){
        Purchase_orderSearchContext context = new Purchase_orderSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Purchase_order> list = new ArrayList<Purchase_order>();
        Page<cn.ibizlab.odoo.core.client.model.Ipurchase_order> clientModelList = purchase_orderClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ipurchase_order clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Purchase_order>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据公司查询
     */
    @Override
    public Page<Purchase_order> selectByOdoo_company(Integer id){
        Purchase_orderSearchContext context = new Purchase_orderSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Purchase_order> list = new ArrayList<Purchase_order>();
        Page<cn.ibizlab.odoo.core.client.model.Ipurchase_order> clientModelList = purchase_orderClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ipurchase_order clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Purchase_order>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据币种查询
     */
    @Override
    public Page<Purchase_order> selectByOdoo_currency(Integer id){
        Purchase_orderSearchContext context = new Purchase_orderSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Purchase_order> list = new ArrayList<Purchase_order>();
        Page<cn.ibizlab.odoo.core.client.model.Ipurchase_order> clientModelList = purchase_orderClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ipurchase_order clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Purchase_order>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据联系人查询
     */
    @Override
    public Page<Purchase_order> selectByOdoo_dest_address(Integer id){
        Purchase_orderSearchContext context = new Purchase_orderSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Purchase_order> list = new ArrayList<Purchase_order>();
        Page<cn.ibizlab.odoo.core.client.model.Ipurchase_order> clientModelList = purchase_orderClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ipurchase_order clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Purchase_order>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据联系人查询
     */
    @Override
    public Page<Purchase_order> selectByOdoo_partner(Integer id){
        Purchase_orderSearchContext context = new Purchase_orderSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Purchase_order> list = new ArrayList<Purchase_order>();
        Page<cn.ibizlab.odoo.core.client.model.Ipurchase_order> clientModelList = purchase_orderClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ipurchase_order clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Purchase_order>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据用户查询
     */
    @Override
    public Page<Purchase_order> selectByOdoo_create(Integer id){
        Purchase_orderSearchContext context = new Purchase_orderSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Purchase_order> list = new ArrayList<Purchase_order>();
        Page<cn.ibizlab.odoo.core.client.model.Ipurchase_order> clientModelList = purchase_orderClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ipurchase_order clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Purchase_order>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据用户查询
     */
    @Override
    public Page<Purchase_order> selectByOdoo_user(Integer id){
        Purchase_orderSearchContext context = new Purchase_orderSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Purchase_order> list = new ArrayList<Purchase_order>();
        Page<cn.ibizlab.odoo.core.client.model.Ipurchase_order> clientModelList = purchase_orderClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ipurchase_order clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Purchase_order>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据用户查询
     */
    @Override
    public Page<Purchase_order> selectByOdoo_write(Integer id){
        Purchase_orderSearchContext context = new Purchase_orderSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Purchase_order> list = new ArrayList<Purchase_order>();
        Page<cn.ibizlab.odoo.core.client.model.Ipurchase_order> clientModelList = purchase_orderClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ipurchase_order clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Purchase_order>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据拣货类型查询
     */
    @Override
    public Page<Purchase_order> selectByOdoo_picking_type(Integer id){
        Purchase_orderSearchContext context = new Purchase_orderSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Purchase_order> list = new ArrayList<Purchase_order>();
        Page<cn.ibizlab.odoo.core.client.model.Ipurchase_order> clientModelList = purchase_orderClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ipurchase_order clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Purchase_order>(list, context.getPageable(), clientModelList.getTotalElements());

    }



    public Ipurchase_order convert2Model(Purchase_order domain , Ipurchase_order model) {
        if(domain == null)
            return model ;
        if(model==null){
            model = purchase_orderClientService.createModel() ;
        }

         if(domain.getIs_shippedDirtyFlag())
            model.setIs_shipped(domain.getIs_shipped());
         if(domain.getWrite_dateDirtyFlag())
            model.setWrite_date(domain.getWrite_date());
         if(domain.getAccess_tokenDirtyFlag())
            model.setAccess_token(domain.getAccess_token());
         if(domain.getActivity_user_idDirtyFlag())
            model.setActivity_user_id(domain.getActivity_user_id());
         if(domain.getMessage_unreadDirtyFlag())
            model.setMessage_unread(domain.getMessage_unread());
         if(domain.getMessage_channel_idsDirtyFlag())
            model.setMessage_channel_ids(domain.getMessage_channel_ids());
         if(domain.getOrder_lineDirtyFlag())
            model.setOrder_line(domain.getOrder_line());
         if(domain.getActivity_date_deadlineDirtyFlag())
            model.setActivity_date_deadline(domain.getActivity_date_deadline());
         if(domain.getNotesDirtyFlag())
            model.setNotes(domain.getNotes());
         if(domain.getAmount_totalDirtyFlag())
            model.setAmount_total(domain.getAmount_total());
         if(domain.getActivity_summaryDirtyFlag())
            model.setActivity_summary(domain.getActivity_summary());
         if(domain.getAmount_taxDirtyFlag())
            model.setAmount_tax(domain.getAmount_tax());
         if(domain.getAccess_urlDirtyFlag())
            model.setAccess_url(domain.getAccess_url());
         if(domain.getInvoice_countDirtyFlag())
            model.setInvoice_count(domain.getInvoice_count());
         if(domain.getAmount_untaxedDirtyFlag())
            model.setAmount_untaxed(domain.getAmount_untaxed());
         if(domain.getPicking_idsDirtyFlag())
            model.setPicking_ids(domain.getPicking_ids());
         if(domain.getCreate_dateDirtyFlag())
            model.setCreate_date(domain.getCreate_date());
         if(domain.getMessage_partner_idsDirtyFlag())
            model.setMessage_partner_ids(domain.getMessage_partner_ids());
         if(domain.getAccess_warningDirtyFlag())
            model.setAccess_warning(domain.getAccess_warning());
         if(domain.get__last_updateDirtyFlag())
            model.set__last_update(domain.get__last_update());
         if(domain.getStateDirtyFlag())
            model.setState(domain.getState());
         if(domain.getMessage_needaction_counterDirtyFlag())
            model.setMessage_needaction_counter(domain.getMessage_needaction_counter());
         if(domain.getActivity_type_idDirtyFlag())
            model.setActivity_type_id(domain.getActivity_type_id());
         if(domain.getPicking_countDirtyFlag())
            model.setPicking_count(domain.getPicking_count());
         if(domain.getMessage_idsDirtyFlag())
            model.setMessage_ids(domain.getMessage_ids());
         if(domain.getMessage_unread_counterDirtyFlag())
            model.setMessage_unread_counter(domain.getMessage_unread_counter());
         if(domain.getMessage_has_errorDirtyFlag())
            model.setMessage_has_error(domain.getMessage_has_error());
         if(domain.getInvoice_idsDirtyFlag())
            model.setInvoice_ids(domain.getInvoice_ids());
         if(domain.getIdDirtyFlag())
            model.setId(domain.getId());
         if(domain.getProduct_idDirtyFlag())
            model.setProduct_id(domain.getProduct_id());
         if(domain.getWebsite_message_idsDirtyFlag())
            model.setWebsite_message_ids(domain.getWebsite_message_ids());
         if(domain.getMessage_has_error_counterDirtyFlag())
            model.setMessage_has_error_counter(domain.getMessage_has_error_counter());
         if(domain.getMessage_is_followerDirtyFlag())
            model.setMessage_is_follower(domain.getMessage_is_follower());
         if(domain.getDate_orderDirtyFlag())
            model.setDate_order(domain.getDate_order());
         if(domain.getMessage_attachment_countDirtyFlag())
            model.setMessage_attachment_count(domain.getMessage_attachment_count());
         if(domain.getMessage_needactionDirtyFlag())
            model.setMessage_needaction(domain.getMessage_needaction());
         if(domain.getMessage_main_attachment_idDirtyFlag())
            model.setMessage_main_attachment_id(domain.getMessage_main_attachment_id());
         if(domain.getDefault_location_dest_id_usageDirtyFlag())
            model.setDefault_location_dest_id_usage(domain.getDefault_location_dest_id_usage());
         if(domain.getNameDirtyFlag())
            model.setName(domain.getName());
         if(domain.getGroup_idDirtyFlag())
            model.setGroup_id(domain.getGroup_id());
         if(domain.getDisplay_nameDirtyFlag())
            model.setDisplay_name(domain.getDisplay_name());
         if(domain.getInvoice_statusDirtyFlag())
            model.setInvoice_status(domain.getInvoice_status());
         if(domain.getActivity_stateDirtyFlag())
            model.setActivity_state(domain.getActivity_state());
         if(domain.getDate_approveDirtyFlag())
            model.setDate_approve(domain.getDate_approve());
         if(domain.getActivity_idsDirtyFlag())
            model.setActivity_ids(domain.getActivity_ids());
         if(domain.getPartner_refDirtyFlag())
            model.setPartner_ref(domain.getPartner_ref());
         if(domain.getMessage_follower_idsDirtyFlag())
            model.setMessage_follower_ids(domain.getMessage_follower_ids());
         if(domain.getDate_plannedDirtyFlag())
            model.setDate_planned(domain.getDate_planned());
         if(domain.getOriginDirtyFlag())
            model.setOrigin(domain.getOrigin());
         if(domain.getUser_id_textDirtyFlag())
            model.setUser_id_text(domain.getUser_id_text());
         if(domain.getFiscal_position_id_textDirtyFlag())
            model.setFiscal_position_id_text(domain.getFiscal_position_id_text());
         if(domain.getCurrency_id_textDirtyFlag())
            model.setCurrency_id_text(domain.getCurrency_id_text());
         if(domain.getCompany_id_textDirtyFlag())
            model.setCompany_id_text(domain.getCompany_id_text());
         if(domain.getDest_address_id_textDirtyFlag())
            model.setDest_address_id_text(domain.getDest_address_id_text());
         if(domain.getWrite_uid_textDirtyFlag())
            model.setWrite_uid_text(domain.getWrite_uid_text());
         if(domain.getPayment_term_id_textDirtyFlag())
            model.setPayment_term_id_text(domain.getPayment_term_id_text());
         if(domain.getCreate_uid_textDirtyFlag())
            model.setCreate_uid_text(domain.getCreate_uid_text());
         if(domain.getPartner_id_textDirtyFlag())
            model.setPartner_id_text(domain.getPartner_id_text());
         if(domain.getPicking_type_id_textDirtyFlag())
            model.setPicking_type_id_text(domain.getPicking_type_id_text());
         if(domain.getIncoterm_id_textDirtyFlag())
            model.setIncoterm_id_text(domain.getIncoterm_id_text());
         if(domain.getCreate_uidDirtyFlag())
            model.setCreate_uid(domain.getCreate_uid());
         if(domain.getPartner_idDirtyFlag())
            model.setPartner_id(domain.getPartner_id());
         if(domain.getDest_address_idDirtyFlag())
            model.setDest_address_id(domain.getDest_address_id());
         if(domain.getCompany_idDirtyFlag())
            model.setCompany_id(domain.getCompany_id());
         if(domain.getCurrency_idDirtyFlag())
            model.setCurrency_id(domain.getCurrency_id());
         if(domain.getPayment_term_idDirtyFlag())
            model.setPayment_term_id(domain.getPayment_term_id());
         if(domain.getUser_idDirtyFlag())
            model.setUser_id(domain.getUser_id());
         if(domain.getWrite_uidDirtyFlag())
            model.setWrite_uid(domain.getWrite_uid());
         if(domain.getIncoterm_idDirtyFlag())
            model.setIncoterm_id(domain.getIncoterm_id());
         if(domain.getFiscal_position_idDirtyFlag())
            model.setFiscal_position_id(domain.getFiscal_position_id());
         if(domain.getPicking_type_idDirtyFlag())
            model.setPicking_type_id(domain.getPicking_type_id());
        return model ;
    }

    public Purchase_order convert2Domain( Ipurchase_order model ,Purchase_order domain) {
        if(model == null)
            return domain ;
        if(domain == null){
            domain = new Purchase_order();
        }

        if(model.getIs_shippedDirtyFlag())
            domain.setIs_shipped(model.getIs_shipped());
        if(model.getWrite_dateDirtyFlag())
            domain.setWrite_date(model.getWrite_date());
        if(model.getAccess_tokenDirtyFlag())
            domain.setAccess_token(model.getAccess_token());
        if(model.getActivity_user_idDirtyFlag())
            domain.setActivity_user_id(model.getActivity_user_id());
        if(model.getMessage_unreadDirtyFlag())
            domain.setMessage_unread(model.getMessage_unread());
        if(model.getMessage_channel_idsDirtyFlag())
            domain.setMessage_channel_ids(model.getMessage_channel_ids());
        if(model.getOrder_lineDirtyFlag())
            domain.setOrder_line(model.getOrder_line());
        if(model.getActivity_date_deadlineDirtyFlag())
            domain.setActivity_date_deadline(model.getActivity_date_deadline());
        if(model.getNotesDirtyFlag())
            domain.setNotes(model.getNotes());
        if(model.getAmount_totalDirtyFlag())
            domain.setAmount_total(model.getAmount_total());
        if(model.getActivity_summaryDirtyFlag())
            domain.setActivity_summary(model.getActivity_summary());
        if(model.getAmount_taxDirtyFlag())
            domain.setAmount_tax(model.getAmount_tax());
        if(model.getAccess_urlDirtyFlag())
            domain.setAccess_url(model.getAccess_url());
        if(model.getInvoice_countDirtyFlag())
            domain.setInvoice_count(model.getInvoice_count());
        if(model.getAmount_untaxedDirtyFlag())
            domain.setAmount_untaxed(model.getAmount_untaxed());
        if(model.getPicking_idsDirtyFlag())
            domain.setPicking_ids(model.getPicking_ids());
        if(model.getCreate_dateDirtyFlag())
            domain.setCreate_date(model.getCreate_date());
        if(model.getMessage_partner_idsDirtyFlag())
            domain.setMessage_partner_ids(model.getMessage_partner_ids());
        if(model.getAccess_warningDirtyFlag())
            domain.setAccess_warning(model.getAccess_warning());
        if(model.get__last_updateDirtyFlag())
            domain.set__last_update(model.get__last_update());
        if(model.getStateDirtyFlag())
            domain.setState(model.getState());
        if(model.getMessage_needaction_counterDirtyFlag())
            domain.setMessage_needaction_counter(model.getMessage_needaction_counter());
        if(model.getActivity_type_idDirtyFlag())
            domain.setActivity_type_id(model.getActivity_type_id());
        if(model.getPicking_countDirtyFlag())
            domain.setPicking_count(model.getPicking_count());
        if(model.getMessage_idsDirtyFlag())
            domain.setMessage_ids(model.getMessage_ids());
        if(model.getMessage_unread_counterDirtyFlag())
            domain.setMessage_unread_counter(model.getMessage_unread_counter());
        if(model.getMessage_has_errorDirtyFlag())
            domain.setMessage_has_error(model.getMessage_has_error());
        if(model.getInvoice_idsDirtyFlag())
            domain.setInvoice_ids(model.getInvoice_ids());
        if(model.getIdDirtyFlag())
            domain.setId(model.getId());
        if(model.getProduct_idDirtyFlag())
            domain.setProduct_id(model.getProduct_id());
        if(model.getWebsite_message_idsDirtyFlag())
            domain.setWebsite_message_ids(model.getWebsite_message_ids());
        if(model.getMessage_has_error_counterDirtyFlag())
            domain.setMessage_has_error_counter(model.getMessage_has_error_counter());
        if(model.getMessage_is_followerDirtyFlag())
            domain.setMessage_is_follower(model.getMessage_is_follower());
        if(model.getDate_orderDirtyFlag())
            domain.setDate_order(model.getDate_order());
        if(model.getMessage_attachment_countDirtyFlag())
            domain.setMessage_attachment_count(model.getMessage_attachment_count());
        if(model.getMessage_needactionDirtyFlag())
            domain.setMessage_needaction(model.getMessage_needaction());
        if(model.getMessage_main_attachment_idDirtyFlag())
            domain.setMessage_main_attachment_id(model.getMessage_main_attachment_id());
        if(model.getDefault_location_dest_id_usageDirtyFlag())
            domain.setDefault_location_dest_id_usage(model.getDefault_location_dest_id_usage());
        if(model.getNameDirtyFlag())
            domain.setName(model.getName());
        if(model.getGroup_idDirtyFlag())
            domain.setGroup_id(model.getGroup_id());
        if(model.getDisplay_nameDirtyFlag())
            domain.setDisplay_name(model.getDisplay_name());
        if(model.getInvoice_statusDirtyFlag())
            domain.setInvoice_status(model.getInvoice_status());
        if(model.getActivity_stateDirtyFlag())
            domain.setActivity_state(model.getActivity_state());
        if(model.getDate_approveDirtyFlag())
            domain.setDate_approve(model.getDate_approve());
        if(model.getActivity_idsDirtyFlag())
            domain.setActivity_ids(model.getActivity_ids());
        if(model.getPartner_refDirtyFlag())
            domain.setPartner_ref(model.getPartner_ref());
        if(model.getMessage_follower_idsDirtyFlag())
            domain.setMessage_follower_ids(model.getMessage_follower_ids());
        if(model.getDate_plannedDirtyFlag())
            domain.setDate_planned(model.getDate_planned());
        if(model.getOriginDirtyFlag())
            domain.setOrigin(model.getOrigin());
        if(model.getUser_id_textDirtyFlag())
            domain.setUser_id_text(model.getUser_id_text());
        if(model.getFiscal_position_id_textDirtyFlag())
            domain.setFiscal_position_id_text(model.getFiscal_position_id_text());
        if(model.getCurrency_id_textDirtyFlag())
            domain.setCurrency_id_text(model.getCurrency_id_text());
        if(model.getCompany_id_textDirtyFlag())
            domain.setCompany_id_text(model.getCompany_id_text());
        if(model.getDest_address_id_textDirtyFlag())
            domain.setDest_address_id_text(model.getDest_address_id_text());
        if(model.getWrite_uid_textDirtyFlag())
            domain.setWrite_uid_text(model.getWrite_uid_text());
        if(model.getPayment_term_id_textDirtyFlag())
            domain.setPayment_term_id_text(model.getPayment_term_id_text());
        if(model.getCreate_uid_textDirtyFlag())
            domain.setCreate_uid_text(model.getCreate_uid_text());
        if(model.getPartner_id_textDirtyFlag())
            domain.setPartner_id_text(model.getPartner_id_text());
        if(model.getPicking_type_id_textDirtyFlag())
            domain.setPicking_type_id_text(model.getPicking_type_id_text());
        if(model.getIncoterm_id_textDirtyFlag())
            domain.setIncoterm_id_text(model.getIncoterm_id_text());
        if(model.getCreate_uidDirtyFlag())
            domain.setCreate_uid(model.getCreate_uid());
        if(model.getPartner_idDirtyFlag())
            domain.setPartner_id(model.getPartner_id());
        if(model.getDest_address_idDirtyFlag())
            domain.setDest_address_id(model.getDest_address_id());
        if(model.getCompany_idDirtyFlag())
            domain.setCompany_id(model.getCompany_id());
        if(model.getCurrency_idDirtyFlag())
            domain.setCurrency_id(model.getCurrency_id());
        if(model.getPayment_term_idDirtyFlag())
            domain.setPayment_term_id(model.getPayment_term_id());
        if(model.getUser_idDirtyFlag())
            domain.setUser_id(model.getUser_id());
        if(model.getWrite_uidDirtyFlag())
            domain.setWrite_uid(model.getWrite_uid());
        if(model.getIncoterm_idDirtyFlag())
            domain.setIncoterm_id(model.getIncoterm_id());
        if(model.getFiscal_position_idDirtyFlag())
            domain.setFiscal_position_id(model.getFiscal_position_id());
        if(model.getPicking_type_idDirtyFlag())
            domain.setPicking_type_id(model.getPicking_type_id());
        return domain ;
    }


}
